package lxs.swift.fn;

import lxs.swift.operation.Try;
import org.jetbrains.annotations.NotNull;

public interface Run<E extends Throwable> extends Fn<Runnable> {
    void run() throws E;

    @Override
    default Runnable std() {
        return () -> Try.runOf(this);
    }

    static <E extends Throwable> Run<E> panic(@NotNull E error) {
        return () -> {
            throw error;
        };
    }


    static <E extends Throwable> Run<E> empty() {
        return () -> {
        };
    }
}
